package net.borlis.sample.services.facade.ws.response;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;

/**
 * @author alex@borlis.net on 04.07.2014.
 */
@XmlRootElement
public class UploadStatusResponse {

    @XmlElement
    private Date uploadDate;

    @XmlElement
    private String uploadStatus;

    public UploadStatusResponse() {
    }

    public UploadStatusResponse(Date uploadDate, String uploadStatus) {
        this.uploadDate = (uploadDate != null ? new Date(uploadDate.getTime()) : null);
        this.uploadStatus = uploadStatus;
    }

    public Date getUploadDate() {
        return this.uploadDate != null ? new Date(this.uploadDate.getTime()) : null;
    }

    public String getUploadStatus() {
        return uploadStatus;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof UploadStatusResponse) {
            UploadStatusResponse other = (UploadStatusResponse) obj;
            EqualsBuilder builder = new EqualsBuilder();
            builder.append(getUploadDate(), other.getUploadDate());
            builder.append(getUploadStatus(), other.getUploadStatus());
            return builder.isEquals();
        }
        return false;
    }

    @Override
    public int hashCode() {
        HashCodeBuilder builder = new HashCodeBuilder();
        builder.append(getUploadDate());
        builder.append(getUploadStatus());
        return builder.toHashCode();
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this).
                append("uploadDate", getUploadDate()).
                append("uploadStatus", getUploadStatus()).
                toString();
    }
}
